const { sign } = Math;

export function range(start: number, stop: number, step?: number): number[] {
    const out = [];
    if (!step) {
        step = sign(stop - start);
    }
    let i = start;
    if (step < 0) {
        while (i > stop) {
            out.push(i);
            i += step;
        }
    } else {
        while (i < stop) {
            out.push(i);
            i += step;
        }
    }
    out.push(stop);
    return out;
}
